package com.huluobo.a2109kotlinshopping.net

import com.huluobo.a2109kotlinshopping.FoodBeanResult
import com.huluobo.a2109kotlinshopping.cart.CartBeanResult
import com.huluobo.a2109kotlinshopping.cart.ChangeCartBeanResult
import com.huluobo.a2109kotlinshopping.category.CategoryBeanResult
import com.huluobo.a2109kotlinshopping.category.CategoryGoodsListBeanResult
import com.huluobo.a2109kotlinshopping.detail.AddToCartBeanResult
import com.huluobo.a2109kotlinshopping.detail.GoodsDetailBeanResult
import com.huluobo.a2109kotlinshopping.home.HomeBannerBeanResult
import com.huluobo.a2109kotlinshopping.home.HomeGoodsBeanResult
import com.huluobo.a2109kotlinshopping.home.HomeNavBeanResult
import com.huluobo.a2109kotlinshopping.login.UserBeanResult
import com.huluobo.a2109kotlinshopping.mine.MineAddressBeanResult
import com.huluobo.a2109kotlinshopping.setting.SettingBeanResult
import io.reactivex.Observable
import okhttp3.RequestBody
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.Query

/**
 *  Created by LC on 2024/1/9.
 */
interface ApiService {
    @GET(Const.URL_FOOD)
    fun getFoods(): Observable<FoodBeanResult>

    //登录请求
    @POST(Const.URL_LOGIN)
    fun login(@Body body: RequestBody): Observable<UserBeanResult>

    //注册接口
    @POST(Const.URL_REGISTER)
    fun register(@Body body: RequestBody): Observable<UserBeanResult>

    //首页接口
    @GET(Const.URL_HOME_GOODS_LIST)
    fun getHomeGoodsList(
        @Query(Const.PARAM_CATEGORY_ID) categoryId: Int,
        @Query(Const.PARAM_CURRENT_PAGE) currentPage: Int,
        @Query(Const.PARAM_PAGE_SIZE) pageSize: Int
    ): Observable<HomeGoodsBeanResult>

    //首页轮播图接口
    @GET(Const.URL_HOME_BANNER)
    fun getHomeBanner(): Observable<HomeBannerBeanResult>

    //首页导航接口
    @GET(Const.URL_HOME_NAV)
    fun getHomeNav(): Observable<HomeNavBeanResult>

    //商品详情接口
    @GET(Const.URL_GOODS_DETAIL)
    fun getGoodsDetail(@Query(Const.PARAM_GOODS_ID) goodsId: Int): Observable<GoodsDetailBeanResult>

    //添加购物车接口
    @POST(Const.URL_ADD_TO_CART)
    fun addToCart(@Body body: RequestBody): Observable<AddToCartBeanResult>

    //查询购物车接口
    @GET(Const.URL_QUERY_CART)
    fun queryCartList(): Observable<CartBeanResult>

    //获取一二级分类接口
    @GET(Const.URL_CATEGORY)
    fun getCategory(): Observable<CategoryBeanResult>

    //获取三级分类接口
    @GET(Const.URL_CATEGORY_GOODS_LIST)
    fun getCategoryGoodsList(
        @Query(Const.PARAM_CATEGORY_ID) categoryId: Int,
        @Query(Const.PARAM_CURRENT_PAGE) currentPage: Int,
        @Query(Const.PARAM_PAGE_SIZE) pageSize: Int
    ): Observable<CategoryGoodsListBeanResult>

    //删除购物车接口
    @POST(Const.URL_DELETE_CART)
    fun deleteCart(@Body body: RequestBody): Observable<ChangeCartBeanResult>

    //购物车加减接口
    @POST(Const.URL_ADD_TO_CART)
    fun changeCart(@Body body: RequestBody): Observable<ChangeCartBeanResult>

    //更新收货地址接口
    @POST(Const.URL_UPDATE_ADDRESS)
    fun updateAddress(@Query(Const.PARAM_ADDRESS) address: String): Observable<MineAddressBeanResult>

    //更新生日
    @POST(Const.URL_BIRTH)
    fun updateBirth(@Query(Const.PARAM_BIRTH) birth: String): Observable<SettingBeanResult>

    //更新昵称
    @POST(Const.URL_NICKNAME)
    fun updateNickname(@Query(Const.PARAM_NICKNAME) nickname: String): Observable<SettingBeanResult>

    //更新性别
    @POST(Const.URL_SEX)
    fun updateSex(@Query(Const.PARAM_SEX) sex: String): Observable<SettingBeanResult>

}